//
//  ApiMoyaBase.swift
//  MySwiftObject
//
//  Created by anscen on 2022/1/10.
//  Copyright © 2022 wangws1990. All rights reserved.
//

import UIKit
import HandyJSON

public  let RefreshPageSize  = 20
public  let moya             = ApiMoyaBase.manager

public class ApiMoyaBase{
    let system      :String = "iOS"
    let timeOut     :TimeInterval = 10//超时

    let uuid        :String = uuid()
    let build       :String = build()
    let version     :String = version()
    let bundleId    :String = bundleId()
    let appName     :String = appName()
    var voiceNumber :Float  = 0

    var landscape :Bool{
        return UIScreen.main.bounds.size.width > UIScreen.main.bounds.size.height
    }

    var safe_width :CGFloat{
        return UIScreen.main.bounds.size.width
    }
    var safe_height :CGFloat{
        return UIScreen.main.bounds.size.height
    }

    var separated :String{
        return "\n\r"
    }
    lazy var user :YMUser = YMUser.user
    lazy var client :YMClient = YMClient.client
    ///MARK:UserDefaults存储的key统一写在这里
    let defaultLogin   = "defaultLogin"//客户端信息
    let defaultClient  = "defaultClient"//客户端信息
    let defaultBookSet = "defaultBookSet"//读书设置
    ///MARK:App的一些信息
    fileprivate static func bundleId() ->String{
        return Bundle.main.bundleIdentifier ?? ""
    }
    fileprivate static func uuid() ->String{
        return UIDevice.current.identifierForVendor?.uuidString ?? ""
    }
    fileprivate static func build() ->String{
        let json = JSON(Bundle.main.infoDictionary as Any)
        return json["CFBundleVersion"].stringValue
    }
    fileprivate static func version() ->String{
        let json = JSON(Bundle.main.infoDictionary as Any)
        return json["CFBundleShortVersionString"].stringValue
    }
    fileprivate static func appName() ->String{
        let json = JSON(Bundle.main.infoDictionary as Any)
        return json["CFBundleDisplayName"].stringValue
    }
    fileprivate static let manager = ApiMoyaBase()
}

